package com.example.dy.pay.controller;

import com.example.dy.pay.service.BasePayService;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.function.Consumer;

@Component("pay_refund")
@Slf4j
public class PayRefundConsumer implements Consumer<PayRefundConsumer.RefundMsgParam> {

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    public static final class RefundMsgParam{
        private String order_no;
        private String svc;
    }

    @Autowired
    private BasePayService basePayService;

    @Override
    public void accept(RefundMsgParam s) {
        log.info(STR."收到退款消息 \{s}");
        basePayService.refund(s.order_no,s.svc);
        log.info(STR."退款结束 \{s}");
    }
}
